<?php

function smarty_function_block( $params, Smarty &$smarty )
{
	$_r = '';
	$action = null;
	$append = null;
	$assign = null;
	
	$attributes = array( );
	foreach( $params as $_k => $_v )
	if( strpos( ',action,assign,append', $_k ) !== false )
	{
		if( strlen( $_v ) ) $$_k = $_v;
	}
	else
	{
		$attributes[ $_k ] = $_v;
	}
	
	//if( isset( $attributes['url'] ) )
	//$attributes['smarty'] =& $smarty;
	
	if( is_null( $action ) ) $_r = 'f%#@!$g s%!t!';
	
	$action = controller::parseAction( $action );
	$c = controller::__getInstanceOf( $action['class'] );
	$_m = $action['method'];
	$_r = $c ->$_m( $attributes );
	
//	if( isset( $attributes['assign'] ) )
//		$smarty ->assign( $attributes['url'], $attributes['urlValue'] );
//	var_dump( array_keys( $smarty ->get_template_vars() ) );
	
	//$_html_result = $env->controllers->$controller->exec($action, $attributes);
	
	if( !is_null( $assign ) )
	{
		$smarty ->assign( $assign, $_r );
	}
	elseif( !is_null( $append ) )
	{
		$smarty ->append( $append, $_r );
	}
	else 
	{
		return $_r;
	}
    
}



?>